// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
        /**(1)坐标点
         * {x,y}
        */
        // 2种方式
        var p_pos = new cc.Vec2(100,100);
        console.log("1:",p_pos);

        p_pos = cc.v2(200,200);
        console.log(p_pos);

        /**(2)Size
         * {width,height}
        */
        var cc_size= new cc.Size(100,100);
        console.log(cc_size);
        cc_size=cc.size(200,200);
        console.log(cc_size);

        /**(3)Rect
         * {x,y,width,height}
         * API:https://docs.cocos.com/creator/api/zh/classes/Rect.html?h=rect
        */
        var cc_Rect=new cc.Rect(10,10,100,100);
        console.log(cc_Rect);
        cc_Rect2=cc.rect(20,20,300,300);
        console.log(cc_Rect2);
        //判断矩形是否相交-intersects
        var bool_intersects=cc_Rect.intersects(cc_Rect2);
        console.log(bool_intersects);

        /**(4)坐标系
         * 
        */
        //节点坐标转屏幕坐标(通常情况下使用带AR)
        var p1=this.node.convertToWorldSpace(cc.v2(0,0));//以左下角为原点
        console.log(p1);
        var p2=this.node.convertToWorldSpaceAR(cc.v2(0,0));//以锚点为原点（AR）
        console.log(p2);
        //屏幕坐标转节点坐标
        var p3=this.node.convertToNodeSpace(p1);//以左下角为原点
        console.log(p3);
        var p4=this.node.convertToNodeSpaceAR(p2);//以锚点为原点（AR）
        console.log(p4);
        
    },

    start () {

    },

    // update (dt) {},
});
